package threading;

import java.util.Scanner;

//方法二：使用Runnable interface来描述线程入口
/*class aa implements Runnable{
    @Override
    public void run() {
        while (true) {
            System.out.println("hello t");
        }
    }
}
public class lianxi {
    public static void main(String[] args) {
        aa runnable = new aa();
        Thread t = new Thread(runnable);
        t.start();
        while(true){
            System.out.println("hello main");
        }
    }
}*/
/*import java.util.*;
public class lianxi {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        int d = scanner.nextInt();

        int A = (a+c)/2;
        int B1 = (b+d)/2;
        int B2 = (c-a)/2;
        int C = (d-b)/2;

        if(B1!=B2){
            System.out.println("No");
        }else{
            System.out.println(A+" " +B1+" "+C);
        }



    }
}*/
//十进制转换x进制
public class lianxi{
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        boolean flg = false;
        String table = "0123456789ABCDEF";
        StringBuilder ret = new StringBuilder();
        if(a < 0){
            a = -a;
            flg = true;
        }
        while(a!=0){
            ret.append(table.charAt(a%b));
            a=a/b;
        }
        if(flg){
            ret.append("-");
        }
        ret.reverse();
        System.out.println(ret);
    }
}
